package co.edu.usbcali.modelo.dto;

import co.edu.usbcali.modelo.ProgramaAcademico;
import co.edu.usbcali.presentation.backEndBeans.ProgramaAcademicoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class ProgramaAcademicoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String nombrePrograma;
    private String codigoPrograma;
    private boolean rowSelected = false;
    private ProgramaAcademicoView programaAcademicoView;
    private ProgramaAcademico programaAcademico;

    public ProgramaAcademico getProgramaAcademico() {
        return programaAcademico;
    }

    public String listener_update(ActionEvent e) {
        try {
            programaAcademicoView.action_modifyWitDTO(((codigoPrograma == null) ||
                codigoPrograma.equals("")) ? null : new Long(codigoPrograma),
                ((nombrePrograma == null) || nombrePrograma.equals("")) ? null
                                                                        : new String(
                    nombrePrograma));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        codigoPrograma = programaAcademico.getCodigoPrograma().toString();
        nombrePrograma = (programaAcademico.getNombrePrograma() != null)
            ? programaAcademico.getNombrePrograma().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        codigoPrograma = programaAcademico.getCodigoPrograma().toString();
        nombrePrograma = (programaAcademico.getNombrePrograma() != null)
            ? programaAcademico.getNombrePrograma().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setProgramaAcademico(ProgramaAcademico programaAcademico) {
        this.programaAcademico = programaAcademico;
    }

    public ProgramaAcademicoView getProgramaAcademicoView() {
        return programaAcademicoView;
    }

    public void setProgramaAcademicoView(
        ProgramaAcademicoView programaAcademicoView) {
        this.programaAcademicoView = programaAcademicoView;
    }

    public String getNombrePrograma() {
        return nombrePrograma;
    }

    public void setNombrePrograma(String nombrePrograma) {
        this.nombrePrograma = nombrePrograma;
    }

    public String getCodigoPrograma() {
        return codigoPrograma;
    }

    public void setCodigoPrograma(String codigoPrograma) {
        this.codigoPrograma = codigoPrograma;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
